﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace Dragon.Prototype1.Infrastructure.Controls
{
    public class Label : WebControl
    {
        public Label(string forId,string text):this(string.Empty,forId,text)
        {

        }
        public Label(string text):this(string.Empty,string.Empty,text)
        { 
            
        }

        public Label(string id, string forId,string text)
        {
            this.ID = id;
            this.Text = text;
            this.ForControlID = forId;
        }

        public string Text
        { get; set; }

        public string ForControlID
        {
            get;
            set;
        }

        protected override HtmlTextWriterTag TagKey
        {
            get
            {
                return HtmlTextWriterTag.Label;
            }
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if(!string.IsNullOrEmpty(this.ForControlID))
                this.Attributes.Add("for", this.ForControlID);

            base.AddAttributesToRender(writer);
        }
        public override void RenderContents(HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(this.Text))
                return;

            writer.Write(Microsoft.Security.Application.AntiXss.HtmlEncode(this.Text));
        }
    }

}
